class Job < ActiveRecord::Base
  ESSENTIAL_NOTE = "The following responsibilities are considered essential to the success of the position."
  NON_ESSENTIAL_NOTE = "The following responsibilities are periodic in nature and, though important, considered non-essential to the success of the position."
  
  validates_presence_of :title, :department, :supervisor, :location, :period_start, :period_end, 
                        :description, :essential_functions

  def set_defaults
    set_default_times
    self.physical_demands = get_default_physical_demands
    self.notice = get_default_notice
    self.how_to_respond = get_default_how_to_respond
    self.footer = get_default_footer
  end

  def set_default_times
    self.period_start = Time.now
    self.period_end = Time.now.next_week
  end

  def copy
    j = Job.new(self.attributes)
    j.id = nil
    j.set_default_times
    j
  end

  private
    def get_default_physical_demands
      rvalue = <<-TEXT
        This position works in a typical office setting. There may be extended periods of sitting, standing and/or bending; listening, talking and/or visual concentration; writing and/or computer use.
      TEXT
      rvalue2 = <<-TEXT2
        This position would normally have routine opportunities to alter physical position or change eye focus. Lifting would not normally exceed 10 pounds.
      TEXT2
      rvalue.strip << "\n\n" << rvalue2.strip
    end

    def get_default_notice
      rvalue = <<-TEXT
      This job description is to be used as a guide for accomplishing Company objectives.  The description incorporates the most typical duties performed and covers only the primary functions and responsibilities of the position.  It is recognized that other related duties not specifically mentioned may also be performed.  The inclusion of those duties would not alter the overall evaluation of this position.
      TEXT
      rvalue.strip
    end

    def get_default_footer
      rvalue = <<-TEXT
      Copyright #{Date.today.year} #{Easel::COMPANY_NAME}. This document contains material which is a proprietary property of and confidential to #{Easel::COMPANY_NAME}.  Disclosure outside #{Easel::COMPANY_NAME} is prohibited except by written permission, license  agreement or other confidentiality agreement.  Unauthorized reproduction or distribution of this document in any form or by any electronic or mechanical means is expressly prohibited.
      TEXT
      rvalue.strip
    end

    def get_default_how_to_respond
      rvalue = <<-TEXT
      Employees who are interested in applying for a job posting need to do so within five (5) business days of the posting date.  
      TEXT
      rvalue.strip
    end
end
